<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div class="box b1 bt-1"></div>
  <div class="box b1 bl-1"></div>
  <div class="box b1 br-1"></div>
  <div class="box b1 bb-1"></div>
  <style>
    .box {
      width: 100px;
      height: 100px;
      margin: 10px;
      background: grey;
    }
    .b1 {
      position: relative;
    }
    .b1::before,
    .b1::after {
      position: absolute;
      content: '';
      display: inline-block;
      background-color: red;
    }
    .bt-1::before,
    .bb-1::after {
      left: 0;
      height: 1px;
      width: 100%;
    }
    .bt-1::before {
      top: 0;
    }
    .bb-1::after {
      bottom: 0;
    }
    .bl-1::before,
    .br-1::after {
      top: 0;
      height: 100%;
      width: 1px;
    }
    .bl-1::before {
      left: 0;
    }
    .br-1::after {
      right: 0;
    }
    @media screen and (-webkit-min-device-pixel-ratio:2){
        .bl-1::before,
        .br-1::after {
          transform:scaleX(0.5);
        }
        .bt-1::before,
        .bb-1::after {
          transform:scaleY(0.5);
        }
    }
    @media screen and (-webkit-min-device-pixel-ratio:3){
        .bl-1::before,
        .br-1::after {
          transform:scaleX(0.33333);
        }
        .bt-1::before,
        .bb-1::after {
          transform:scaleY(0.33333);
        }
    }
  </style>
</body>
</html>